﻿using System;
using System.ComponentModel.Design;
using System.IO;
using System.Text;

namespace DataReading
{
    class Program
    {
        public static List<string> title = new List<string>();
        public static List<string> content = new List<string>();
        public static List<string> summery = new List<string>();
        public static List<string> website = new List<string>();
        public static void Main(string[] args)
        {
            var path = @"D:\360MoveData\Users\LENOVO\Desktop\SQL Management\0.txt";
            var path1 = @"D:\360MoveData\Users\LENOVO\Desktop\network\0.txt";
            using (FileStream stream = File.Open(path1, FileMode.OpenOrCreate, FileAccess.Write))
            {
                stream.Seek(0, SeekOrigin.Begin);
                stream.SetLength(0);
            }
            string[] ReadText = File.ReadAllLines(path, Encoding.UTF8);
            foreach (string item in ReadText)
            {
                //Console.WriteLine(item);
                //if (item.Contains("content type") || item.Contains("title type") || item.Contains("summary type")|| item.Contains("link rel=\"alternate\" type=\"text/html\""))
                //{
                //    using (StreamWriter writer = new StreamWriter(path1, true))
                //    {
                        
                //        writer.WriteLine(item.Replace(@"<title type=""text"">", ""));
                //    }
                //}
                if(item.Contains("content type"))
                {
                        string m = item.Remove(1, 24);
                        string n = m.Replace(@"</content>", "");
                    using (StreamWriter writer = new StreamWriter(path1, true))
                    {

                               writer.WriteLine(n);
                            }
                }
                else if (item.Contains("title type"))
                {

                        string m = item.Replace(@"<title type=""text"">", "");
                        string n = m.Replace(@"</title>", "");
                        string x = n.Replace(@"<subtitle type=""text"">", "");
                        string y = x.Replace(@"</subtitle>", "");
                    using (StreamWriter writer = new StreamWriter(path1, true))
                    {

                        writer.WriteLine(y);
                    }

                }
                else if (item.Contains("summary type"))
                {

                        string m = item.Replace(@"<summary type=""text"">", "");
                        string n = m.Replace(@"</summary>", "");
                    using (StreamWriter writer = new StreamWriter(path1, true))
                    {

                        writer.WriteLine(n);
                    }
                }
                else if (item.Contains("link rel=\"alternate\" type=\"text/html\""))
                {

                        string m = item.Replace(@"<link rel=""alternate"" type=""text/html"" href=""", "");
                        string n = m.Replace(@""" />", "");
                    using (StreamWriter writer = new StreamWriter(path1, true))
                    {

                        writer.WriteLine(n);
                    }
                }
            }
        } 
    }
    
}